﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Model
{
    public class IllegalPasswordRecordRepository
    {
        private JzSportDbContext _dbContext;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbContext"></param>
        public IllegalPasswordRecordRepository(JzSportDbContext dbContext)
        {
            _dbContext = dbContext;
        }

        public void Create(IllegalPasswordRecord record)
        {
            _dbContext.Set<IllegalPasswordRecord>().Add(record);
        }

        public List<IllegalPasswordRecord> Get(int userId)
        {
            return _dbContext.Set<IllegalPasswordRecord>().Where(p => p.UserId == userId && p.IsValid).ToList();
        }

        public void Update(IllegalPasswordRecord record)
        {
            _dbContext.Entry<IllegalPasswordRecord>(record).State = System.Data.EntityState.Modified;
        }
    }
}
